package cn.ld.fj.web.account;

import cn.ld.fj.entity.account.User;
import cn.ld.fj.service.account.AccountManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by zuohao on 2017/8/3.
 */

@Controller
@RequestMapping("loginController")
public class LoginController {

    @Autowired
    private AccountManager accountManager;

    @RequestMapping(value = "login",method = RequestMethod.POST)
    @ResponseBody
    public Map login(@RequestParam("account")String account,@RequestParam("password")String password){
        User user=accountManager.getUserListByAccountAndPassword(account,password);
        Map<String,Object> resultMap=new HashMap<>();
        if (user!=null){
            resultMap.put("status","success");
            resultMap.put("userInfo",user);
        }else {
            resultMap.put("status","false");
        }
        return resultMap;
    }


}
